<style>
.evaluate-page{
	width: 750upx;
	box-sizing: border-box;
	display: flex;
	flex-direction: column;
	align-items: center;
	padding: 40upx;
}
.evaluate-page .textarea{
	width: 100%;
	border: 2upx solid #aaa;
	/* padding: 16upx 10upx 10upx 10upx; */
	padding: 10upx;
	font-size: 28upx;
	box-sizing: border-box;
	line-height: normal;
}

.evaluate-page .saveEvaluate{
	margin:0 auto;
	margin-top: 30upx;
	width: 100%;
	font-size: 30upx;
}
</style>
<template>
	<view class="evaluate-page">
		 <textarea class="textarea" @input="inputAppraise"  placeholder="请输入租赁评价"/>
		 <button type="primary" class="saveEvaluate" @click="save">提交</button>
	</view>
</template>

<script>
	
	import {
	    mapState,
	    mapMutations
	} from 'vuex'
	export default {
		data() {
			return {
				id:'',
				appraise:''
			}
		},
		
		methods: {
			...mapMutations(['setevaluateID']),
			save(){
				console.log(this.id,this.appraise);
				if(!this.appraise){
					uni.showToast({
						title:'请输入评价内容',
						mask:true
					})
					return
				}
				let that = this
				uni.request({
					url: this.httpUrl + 'resLease/appraise',
					method: 'POST',
					header: {
						'content-type': 'application/x-www-form-urlencoded'
					},
					data: {
						id: that.id,
						appraise: that.appraise
					},
					success: (res) => {
						// console.log(res)
						if (res.data.code == 1) {
							that.setevaluateID(that.id)
							uni.showToast({
								title:'您已评价',
								mask:true
							})
							setTimeout(()=>{
								uni.navigateBack({
									delta:1
								})
							},2000)
							
						} else {
							uni.showToast({
								title: res.data.msg,
								icon: 'none',
								mask: true
							})
						}
					}
				})
				
				
			},
			inputAppraise(event){
				this.appraise = event.detail.value
			}
		},
		onLoad(options) {
			this.id = options.id
		}
	}
</script>
